package com.zyd.controller.city;

import com.zyd.constants.ErrorDef;
import com.zyd.io.model.CountyEntity;
import com.zyd.io.model.CountyEntityExample;
import com.zyd.io.vo.res.ResBody;
import com.zyd.mappers.CountyEntityMapper;
import com.zyd.service.city.CityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/areas")
public class CityContoller {

    private static final Logger LOGGER = LoggerFactory.getLogger(CityContoller.class);

    @Autowired
    private CityService cityService;

    @PostMapping
    public ResBody queryAreas() {
        try {
            ResBody resBody = new ResBody(ErrorDef.SUCCESS, "查询省市县成功");
            resBody.setData(cityService.findCitys());
            return resBody;
        } catch (Exception e) {
            LOGGER.error("查询地区失败", e);
            return  new ResBody(ErrorDef.UPLOAD_IMG_ERROR, "查询省市县失败");
        }
    }
}
